import request from '@/utils/request'


export async  function   getCompanies() {
  let res =  await request({
    url: '/Companies',
    method: 'get',
  })
 
  return res.data.value;
}
export async function updateCompany(company){
  let res =  await request({
    url: `/Companies(${company.CompanyId})`,
    method: 'put',
    data: company
  })
  return res.data.value;
}
export async function addCompany(company){
  //
  let res =  await request({
    url: '/Companies',
    method: 'post',
    data: company,
  })
  return res.data;
  //
  // return  new Promise(  (resolve, reject) => {
  //   var id = datas[datas.length-1].id+1;
  //   var temp= {id:id,name:roomName}
  //   datas.push(temp);
  //   resolve(temp);
  // });
}
export function removeCompany(id){
  return request({
    url: `/Companies/${id}`,
    method: 'delete',
  })



}
